<?
REQUIRE("../../include/connect.php");

$query="SELECT con_invention FROM sdconnp where con_id=1";
echo $query;
$resultat=mysql_query($query);
$tmp=mysql_fetch_row($resultat);
$inventiontmp=EXPLODE("/",$tmp[0]);

echo"<br>";

FOREACH($inventiontmp as $element){
    if ($drap==1){ $querytmp.=" OR ";}ELSE{$querytmp.=" WHERE ";}
    $i=$element;
    $invention[$i]=1;
    $querytmp.="invention_precedent=$i";
    $drap=1;
}    //Fin du foreach





$query="SELECT invention_id, invention_name,invention_prerequis FROM invention $querytmp AND invention_categorie='magie'";
echo $query;
$resultat=mysql_query($query);
$tmp=mysql_fetch_row($resultat);




WHILE ($request=mysql_fetch_array($resultat)){

$idinvention=$request[0];
$prerequis=EXPLODE("/",$request[2]);
$binvention=0;

      if (!empty($prerequis[0])){
       FOREACH($prerequis as $element){
            IF ($invention[$element]!=1){
                $binvention=1;

            }
            
   }
            
       }//Fin du foreach


IF ($binvention==0 && $invention[$idinvention]!=1){
    echo $request[2];
echo"<br> $request[0] :$request[1] / $request[2]";
}
       
}//Fin du while.

?>
